package shuogg.test.servletbase;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 
 * @author linshuo
 *
 * 关于路径: 左边有/的根目录为classes里面, 和shuogg文件夹同目录;
 *          左边没有/则根目录在servletbase里面, 跟.class文件同目录;
 *
 */

public class Dispatcher extends HttpServlet {
    private static final long serialVersionUID = 1L;
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        RequestDispatcher rd = req.getRequestDispatcher("/OutHtml"); 
        //rd.forward(req, resp); //请求转发: 此时Dispatcher只允许输出响应头,不允许响应体; OutHtml则两者均可输出;
        rd.include(req, resp);   //请求包含: 此时Dispatcher响应头和响应体均可输出; OutHtml两者也均可输出; 
        
        System.out.println("I am Dispather, Now go to Dispatcher Servlet!");

    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) {

    }

}
